
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.LayerManager;
import javax.microedition.lcdui.game.Sprite;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Abahe
 */
public class SplashScreen extends GameCanvas implements Runnable {

    private MainMIDlet midlet;
    private boolean running = false;
    private int loop = 0;
    private Thread thread = null;
    //speed
    private int speedGame = 100;
    //image
    private Image imgLogoArthur;
    private String pathLogoAlthur = "";

    public SplashScreen(MainMIDlet midlet) {
        super(false);
        this.midlet = midlet;
        setFullScreenMode(true);

        pathLogoAlthur = "/althur.png";

        try {
            imgLogoArthur = Image.createImage(pathLogoAlthur);
        } catch (IOException ex) {
        }
    }

    public void start() {
        running = true;
        thread = new Thread(this);
        thread.start();
    }

    public void stop(){
        running = false;
    }

    public void run() {
        Graphics g = getGraphics();
        while (running) {
            drawDisplay(g);
            loop++;
            System.out.println(loop);

            if (loop > 20) {
                System.out.println("oi!");
                midlet.showMenuCanvas();
            }

            try {
                Thread.sleep(speedGame);
            } catch (InterruptedException ie) {
            }
        }



    }

    protected void drawDisplay(Graphics g) {
        g.setColor(0xffffff);
        g.fillRect(0, 0, getWidth(), getHeight());

        g.drawImage(imgLogoArthur, 0, 0, Graphics.TOP | Graphics.LEFT);

        //flush off-screen buffer to display
        flushGraphics();
    }
}
